package sale

import (
	"dhfshop/models/sale"
	"dhfshop/controllers/base"
	//"github.com/astaxie/beego"
	"github.com/astaxie/beego/validation"
)

// 首页管理
type HomeController struct {
	base.BaseController
}

// 获取首页数据
func (this *HomeController) IndexList() {
    v := struct {
		Type    int     `form:"type" valid:"Required"`
	    Client  string  `form:"client" valid:"Required"`
	}{}
	this.ParseForm(&v)
	valid := validation.Validation{}
	passed, _ := valid.Valid(&v)
	if !passed {
	    this.ServeError(valid.Errors[0].Key+" "+valid.Errors[0].Message)
		return
	}
	if shop_id, err := this.GetInt("shop_id"); err == nil {
	    sale.GetHomeId(int64(shop_id))
	}else{
	    this.ServeError(err.Error())
	    return
	}
	this.ServeJSON()
}

